package com.danielepelagatti.flickrmanager.commands.people
{
	import com.adobe.webapis.flickr.Photo;
	import com.adobe.webapis.flickr.events.FlickrResultEvent;
	import com.danielepelagatti.flickrmanager.commands.FlickrCommand;
	import com.danielepelagatti.flickrmanager.commands.IFlickrCommand;
	import com.danielepelagatti.flickrmanager.model.Flickr;
	import com.danielepelagatti.flickrmanager.model.LocalUser;
	import com.danielepelagatti.flickrmanager.model.PhotoCollection;
	import com.danielepelagatti.flickrmanager.model.States;
	/**
	 * 
	 * @author dpelagatti
	 * 
	 */
	public class GetPublicPhotos extends FlickrCommand implements IFlickrCommand
	{
		/**
		 * 
		 * @param event
		 * 
		 */		
		public function error(event:FlickrResultEvent):Boolean
		{
			return false;
		}
		/**
		 * 
		 * @param event
		 * 
		 */		
		public function success(event:FlickrResultEvent):void
		{	
			LocalUser.getInstance().photoCollection = new PhotoCollection();
			
			for (var i:String in event.data.photos.photos)
			{
				LocalUser.getInstance().photoCollection.addItem(Photo(event.data.photos.photos[i]));
			}
			
		}
		/**
		 * 
		 * @return 
		 * 
		 */		
		public function getAPICall():Function
		{
			return flickr.people.getPublicPhotos;
		}
	}
}